{#- Template for "Attributes" sections in docstrings.

This template renders a list of documented attributes in the format
specified with the [`docstring_section_style`][] configuration option.

Context:
  section (griffe.DocstringSectionAttributes): The section to render.
-#}

{% block logs scoped %}
  {#- Logging block.
  
  This block can be used to log debug messages, deprecation messages, warnings, etc.
  -#}
  {{ log.debug("Rendering attributes section") }}
{% endblock logs %}

<style>
.md-grid {
  max-width: 1920px !important;
}
</style>

{% import "language"|get_template as lang with context %}
{#- Language module providing the `t` translation method. -#}

{% if config.docstring_section_style == "table" %}
  {% block table_style scoped %}
    {#- Block for the `table` section style. -#}
    <p><span class="doc-section-title">{{ section.title or lang.t("Attributes:") }}</span></p>
    <table>
      <thead>
        <tr>
          <th>{{ lang.t("Name") }}</th>
          <th>{{ lang.t("Type") }}</th>
          <th>{{ lang.t("Description") }}</th>
          <th>{{ lang.t("Default") }}</th>
        </tr>
      </thead>
      <tbody>
        {% for attribute in section.value %}
          <tr class="doc-section-item">
            <td><code>{{ attribute.name }}</code></td>
            <td>
              {% if attribute.annotation %}
                {% with expression = attribute.annotation %}
                  <code>{% include "expression"|get_template with context %}</code>
                {% endwith %}
              {% endif %}
            </td>
            <td>
              <div class="doc-md-description">
                {{ attribute.description|convert_markdown(heading_level, html_id, autoref_hook=autoref_hook) }}
              </div>
            </td>
            <td>
              <code>
                {% if attribute.value %}
                  {{ attribute.value|e }}
                {% else %}
                  {% for member_name, member in obj.members.items() %}
                    {% if member_name == attribute.name and member.value %}
                      {{ member.value|e }}
                    {% endif %}
                  {% endfor %}
                  {% for member_name, member in obj.inherited_members.items() %}
                    {% if member_name == attribute.name and member.value %}
                      {{ member.value|e }}
                    {% endif %}
                  {% endfor %}
                {% endif %}
              </code>
            </td>
          </tr>
        {% endfor %}
      </tbody>
    </table>
  {% endblock table_style %}
{% elif config.docstring_section_style == "list" %}
  {% block list_style scoped %}
    {#- Block for the `list` section style. -#}
    <p><span class="doc-section-title">{{ section.title or lang.t("Attributes:") }}</span></p>
    <ul>
      {% for attribute in section.value %}
        <li class="doc-section-item field-body">
          <b><code><autoref identifier="{{ obj.path }}.{{ attribute.name }}" optional hover>{{ attribute.name }}</autoref></code></b>
          {% if attribute.annotation %}
            {% with expression = attribute.annotation %}
              (<code>{% include "expression"|get_template with context %}</code>)
            {% endwith %}
          {% endif %}
          –
          <div class="doc-md-description">
            {{ attribute.description|convert_markdown(heading_level, html_id, autoref_hook=autoref_hook) }}
          </div>
        </li>
      {% endfor %}
    </ul>
  {% endblock list_style %}
{% elif config.docstring_section_style == "spacy" %}
  {% block spacy_style scoped %}
    {#- Block for the `spacy` section style. -#}
    <table>
      <thead>
        <tr>
          <th><span class="doc-section-title">{{ (section.title or lang.t("ATTRIBUTE")).rstrip(":").upper() }}</span></th>
          <th><span>{{ lang.t("DESCRIPTION") }}</span></th>
        </tr>
      </thead>
      <tbody>
        {% for attribute in section.value %}
          <tr class="doc-section-item">
            <td><code><autoref identifier="{{ obj.path }}.{{ attribute.name }}" optional hover>{{ attribute.name }}</autoref></code></td>
            <td class="doc-attribute-details">
              <div class="doc-md-description">
                {{ attribute.description|convert_markdown(heading_level, html_id, autoref_hook=autoref_hook) }}
              </div>
              <p>
                {% if attribute.annotation %}
                  <span class="doc-attribute-annotation">
                    <b>TYPE:</b>
                    {% with expression = attribute.annotation %}
                      <code>{% include "expression"|get_template with context %}</code>
                    {% endwith %}
                  </span>
                {% endif %}
              </p>
            </td>
          </tr>
        {% endfor %}
      </tbody>
    </table>
  {% endblock spacy_style %}
{% endif %}